package com.steve.mac.tools.hadooptest.mapper;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * designed by Steve Ke on 2017/12/19.
 *
 * @author Steve Ke
 *         e-mail  huangke7296@foxmail.com
 *         github  https://github.com/KoreHuang
 *         oschina https://git.oschina.net/steveKe
 * @version JDK 1.8.0_111
 * @since 2017/12/19
 */
public class MaxTemperatureMapper
        extends Mapper<LongWritable,Text,Text,IntWritable> {


    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String line =value.toString();
        String year=line.substring(15,19);

        int airTemperature=Integer.parseInt(line.substring(87,92));
        context.write(new Text(year),new IntWritable(airTemperature));

    }



}
